'use strict';

const Controller = require('egg').Controller;

class BasicController extends Controller {
      success(data) {
            const { response } = this.ctx;
            response.body = {
                  code: 0,
                  data
            }
      }

      message(msg) {
            const { response } = this.ctx;
            response.body = {
                  code: 0,
                  msg
            }
      }

      error(errorMsg, code = -1) {
            const { response } = this.ctx;
            response.body = {
                  code: code,
                  msg: errorMsg
            }
      }
}

module.exports = BasicController;
